<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

</head>

<body>
    <script>
        var baseURL = 'http://localhost:3000';
        // 返回的结果是promise对象    
        // get请求
        axios({
            method: 'get',
            url: baseURL + '/api/getaxios3',
            params: {
                id: 'u0001',
                username: '王文博'
            }
        }).then((res) => {
            console.log(res);
            console.log(res.data);
        });
        // post请求
        axios({
            method: 'post',
            url: baseURL + '/api/postaxios1',
            data: {
                id: 'u0002',
                username: '文文'
            }
        }).then((res) => {
            console.log(res.data);
        });
    </script>
</body>

</html>